﻿using Box2DSharp.Dynamics;

namespace TrinityEngine
{
    public class PhysicsWorld
    {
        private World _world;

        public PhysicsWorld()
        {
            _world = new World(new System.Numerics.Vector2(0f, -9.8f));
            _world.AllowSleep = true;
            _world.WarmStarting = true;
            _world.ContinuousPhysics = true;
            _world.SubStepping = true;
        }

        public void CreateBody(BodyDef def)
        {
            _world.CreateBody(def);
        }

        public void DestroyBody(Body body)
        {
            _world.DestroyBody(body);
        }

        public void Update()
        {
            _world.Step(Time.fixedDeltaTime, 8, 3);
        }
    }
}
